package com.share.drools.state;

import org.kie.api.KieServices;
import org.kie.api.logger.KieRuntimeLogger;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;

/**
 * @author caifan
 * @created 2021/4/2
 * description:
 */
public class StateUsingAgendaGroup {

    public static void main(String[] args) {
        KieServices ks = KieServices.Factory.get();
        KieContainer kc = ks.getKieClasspathContainer();
        execute(kc, ks);
    }

    public static void execute(KieContainer kieContainer, KieServices ks) {
        KieSession kieSession = kieContainer.newKieSession("StateAgendaGroupKS");

        KieRuntimeLogger logger = ks.getLoggers().newConsoleLogger(kieSession);

        final State a = new State("A");
        final State b = new State("B");
        final State c = new State("C");
        final State d = new State("D");

        kieSession.insert(a);
        kieSession.insert(b);
        kieSession.insert(c);
        kieSession.insert(d);

        kieSession.fireAllRules();
        logger.close();
        kieSession.dispose();

    }

}
